<!DOCTYPE html>
<html ng-app="app">
<head>
<title>邮件通知平台</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link rel="stylesheet"
	href="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap.min.css">

<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
        <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
        <script src="http://cdn.bootcss.com/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
</head>
<body>
	<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
	<script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js">
		
	</script>
	<!-- Include all compiled plugins (below), or include individual files as needed -->
	<script
		src="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
	<script src="angular-1.2.9/angular.min.js"></script>
	<script src="angular-1.2.9/angular-route.min.js"></script>
	<script src="angular-1.2.9/angular.min.js"></script>
	<script type="text/javascript">
		angular.module('app', [ 'ngRoute' ])
		.controller("mail_conf",
			function($scope) {
				$scope['mail'] = {};

				loadData();

				$scope['saveConfig'] = function() {
					$.post('config/mail/save.do', $scope['mail'], function(result) {
						loadData();
					});
				}

				$scope['testConfig'] = function() {
					$('#myModal').modal({
						'show' : true,
						backdrop : 'static'
					})
					$.post('config/mail/test.do', $scope['mail'], function(result) {
						$('#myModal').modal('hide')
						alert(result)
					});
				}
				
				
				function loadData(){
					$.getJSON('config/mail.do', function(data) {
						$scope.$apply(function() {
							$scope['mail'] = data;
						});
					});
				}
			})
		.controller("index_nav",function($scope,$location){
			$scope.location = $location;
		})
		.config(function($routeProvider) {
			$routeProvider.when('/data_list', {
				templateUrl : 'data_list.htm',
				controller : 'data_list'
			}).when('/intro', {
				templateUrl : 'intro.htm'
			}).when('/user_conf', {
				controller : 'user_conf',
				templateUrl : 'user_conf.htm'
			}).when('/mail_conf', {
				controller : 'mail_conf',
				templateUrl : 'mail_conf.htm'
			}).otherwise({
				redirectTo : '/intro'
			});
		})
	</script>

	<div class="navbar navbar-inverse navbar-static-top" role="navigation">
		<div class="container">
			<div class="navbar-header">
				<a class="navbar-brand" href="#/intro">邮件通知系统</a>
			</div>
			<div class="collapse navbar-collapse" ng-controller="index_nav">
				<ul class="nav navbar-nav">
					<li class="{{location.path().indexOf('intro')>0?'active':''}}"><a href="#/intro">使用说明</a></li>
					<li class="{{location.path().indexOf('data_list')>0?'active':''}}"><a href="#/data_list">所有通知</a></li>
					<li class="{{location.path().indexOf('user_conf')>0?'active':''}}"><a href="#/user_conf">通知接受者配置</a></li>
					<li class="{{location.path().indexOf('mail_conf')>0?'active':''}}"><a href="#/mail_conf">通知发送邮箱配置</a></li>
				</ul>
			</div>
			<!--/.nav-collapse -->
		</div>
	</div>

	<div class="container">
		<div ng-view></div>
	</div>

</body>
</html>

